<!DOCTYPE html>
<html>
<head>
    <title>服务健康看板</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        :root {
            --primary-color: #1890ff;
            --success-color: #52c41a;
            --warning-color: #faad14;
            --error-color: #ff4d4f;
            --bg-color: #f0f2f5;
            --header-bg: #fff;
            --border-color: #f0f0f0;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            background-color: var(--bg-color);
            color: #333;
            line-height: 1.5;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }

        .header {
            background: var(--header-bg);
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.05);
            margin-bottom: 24px;
        }

        .header h1 {
            color: #1f1f1f;
            font-size: 24px;
            margin-bottom: 16px;
        }

        .summary-cards {
            display: flex;
            gap: 16px;
            margin-bottom: 24px;
        }

        .summary-card {
            background: #fff;
            padding: 20px;
            border-radius: 8px;
            flex: 1;
            box-shadow: 0 2px 8px rgba(0,0,0,0.05);
        }

        .summary-card h3 {
            font-size: 14px;
            color: #666;
            margin-bottom: 8px;
        }

        .summary-card .number {
            font-size: 24px;
            font-weight: bold;
        }

        .normal .number {
            color: var(--success-color);
        }

        .abnormal .number {
            color: var(--error-color);
        }

        .status-table-container {
            background: #fff;
            padding: 24px;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.05);
        }

        .status-table {
            width: 100%;
            border-collapse: separate;
            border-spacing: 0;
            border-radius: 8px;
            overflow: hidden;
        }

        .status-table th {
            background: #fafafa;
            padding: 16px;
            text-align: left;
            font-weight: 500;
            color: #666;
            border-bottom: 1px solid var(--border-color);
        }

        .status-table td {
            padding: 16px;
            border-bottom: 1px solid var(--border-color);
        }

        .status-table tr:hover {
            background: #fafafa;
        }

        .status-table tr:last-child td {
            border-bottom: none;
        }

        .check-icon {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 24px;
            height: 24px;
            border-radius: 50%;
        }

        .status-normal .check-icon {
            background: rgba(82, 196, 26, 0.1);
            color: var(--success-color);
        }

        .status-abnormal .check-icon {
            background: rgba(255, 77, 79, 0.1);
            color: var(--error-color);
        }

        .status-warning .check-icon {
            background: rgba(255, 173, 20, 0.1);
            color: var(--warning-color);
        }

        .date-header {
            font-size: 13px;
            text-align: center !important;
        }

        .service-name {
            font-weight: 500;
            color: #1f1f1f;
        }

        .refresh-time {
            color: #666;
            font-size: 13px;
            margin-top: 8px;
        }

        .total .number {
            color: var(--primary-color);
        }

        .type-summary {
            background: #fff;
            padding: 20px;
            border-radius: 8px;
            margin-bottom: 24px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.05);
        }

        .type-summary h3 {
            margin-bottom: 16px;
            color: #333;
        }

        .type-cards {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 16px;
        }

        .type-card {
            background: #f5f5f5;
            padding: 16px;
            border-radius: 6px;
            text-align: center;
        }

        .type-card h4 {
            color: #666;
            margin-bottom: 8px;
        }

        .type-card .count {
            font-size: 20px;
            font-weight: bold;
            color: var(--primary-color);
        }

        .metric-info {
            padding: 8px 12px;
        }

        .metric-name {
            font-weight: 500;
            color: #1f1f1f;
            margin-bottom: 4px;
        }

        .metric-threshold {
            font-size: 12px;
            color: #666;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>服务健康看板</h1>
            <div class="refresh-time">
                最后更新时间: {{now | date "2006-01-02 15:04:05"}}
            </div>
        </div>

        <div class="summary-cards">
            <div class="summary-card total">
                <h3>总指标数</h3>
                <div class="number">{{.Summary.TotalMetrics}}</div>
            </div>
            <div class="summary-card normal">
                <h3>正常服务</h3>
                <div class="number">{{.Summary.Normal}}</div>
            </div>
            <div class="summary-card abnormal">
                <h3>异常服务</h3>
                <div class="number">{{.Summary.Abnormal}}</div>
            </div>
            <div class="summary-card warning">
                <h3>警告服务</h3>
                <div class="number">{{.Summary.Warning}}</div>
            </div>
        </div>

        <div class="type-summary">
            <h3>指标类型统计</h3>
            <div class="type-cards">
                {{range $type, $count := .Summary.TypeCounts}}
                <div class="type-card">
                    <h4>{{$type}}</h4>
                    <div class="count">{{$count}}</div>
                </div>
                {{end}}
            </div>
        </div>

        <div class="status-table-container">
            <table class="status-table">
                <thead>
                    <tr>
                        <th>指标信息</th>
                        {{range $date := .Dates}}
                        <th class="date-header">{{$date}}</th>
                        {{end}}
                    </tr>
                </thead>
                <tbody>
                    {{range $metric := .Metrics}}
                    <tr>
                        <td class="metric-info">
                            <div class="metric-name">{{$metric.Name}}</div>
                            <div class="metric-threshold">
                                阈值: {{$metric.Threshold}}{{$metric.Unit}}
                                {{if eq $metric.ThresholdType "greater"}}
                                    (>报警)
                                {{else if eq $metric.ThresholdType "greater_equal"}}
                                    (>=报警)
                                {{else if eq $metric.ThresholdType "less"}}
                                    (<报警)
                                {{else if eq $metric.ThresholdType "less_equal"}}
                                    (<=报警)
                                {{else if eq $metric.ThresholdType "equal"}}
                                    (=正常)
                                {{else if eq $metric.ThresholdType "not_equal"}}
                                    (!=正常)
                                {{end}}
                            </div>
                        </td>
                        {{range $date := $.Dates}}
                        <td class="{{if eq (index $metric.DailyStatus $date) "normal"}}status-normal{{else if eq (index $metric.DailyStatus $date) "warning"}}status-warning{{else}}status-abnormal{{end}}">
                            <span class="check-icon">
                                {{if eq (index $metric.DailyStatus $date) "normal"}}
                                ✓
                                {{else if eq (index $metric.DailyStatus $date) "warning"}}
                                ⚠
                                {{else}}
                                ✗
                                {{end}}
                            </span>
                        </td>
                        {{end}}
                    </tr>
                    {{end}}
                </tbody>
            </table>
        </div>
    </div>
</body>
</html>
